package net.cn_su.sharpeyes.playback;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import net.cn_su.sharpeyes.components.PlaybackTimeItem;
import net.cn_su.sharpeyes.components.PlaybackTimeItem_;

import org.androidannotations.annotations.EBean;
import org.androidannotations.annotations.RootContext;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/**
 * Created by Overlord on 2016/08/18.
 * Singularity Universe
 */
@EBean
public class DateTimeAdapter extends BaseAdapter {

    @RootContext
    protected Context context;

    private List<Calendar> calendars = null;

    public void setCalendars(List<Calendar> calendars) {
        this.calendars = calendars;
    }

    @Override
    public int getCount() {
        return calendars != null ? calendars.size() : 0;
    }

    @Override
    public Calendar getItem(int i) {
        return calendars != null ? calendars.get(i) : null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
        PlaybackTimeItem item = null;
        if(view != null){
            item = (PlaybackTimeItem)view;
        }else{
            item = PlaybackTimeItem_.build(context);
        }
        item.bindData(getItem(i));
        return item;
    }
}
